//
//  RefusedViewController.m
//  SeaMelonSeeds_Counselor
//
//  Created by 尤振宇 on 2017/8/10.
//  Copyright © 2017年 杨笑. All rights reserved.
//

#import "RefusedViewController.h"
#import "CustomTextView.h"
#import "OrderApi.h"

@interface RefusedViewController ()
@property (weak, nonatomic) IBOutlet CustomTextView *textview;

@end

@implementation RefusedViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"说明";
    self.textview.placeholder = @"在此输入说明理由";
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)complete:(id)sender {
    
    if (![self.textview hasText]) {
        return [MBProgressHUD showError:@"请说明理由"];
    }
    
    WeakSelf(self)
    OrderApi *api = [[OrderApi alloc]initRequestRefuse:self.order.id reason:self.textview.text];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (kCode(request.responseJSONObject)) {
            [MBProgressHUD showSuccess:@"拒绝成功"];
            weakself.updataViewController.isViewWillAppearUpdata = YES;
            [Tool SendMessage_RefuseOrder:_order.id hx_username:_order.user_hx];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
